<template>
  <view class="auther-box">
    <!-- <image class="logo-img" src="/static/img/index1.png" mode="widthFix"> -->
    <image class="logo-img" src="/static/img/index1.png" mode="widthFix"></image>
    <view class="btn">
      <button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">授权登录（实际上是绑定手机号）</button>
    </view>
  </view>
</template>

<script lang="ts">
// @ts-nocheck
import {decryptData} from "../../api/common/login";
import Vue from 'vue';

export default Vue.extend({
  name: "login_code",
  onLoad(option) {
    // checkLogin().then()
  },

  methods: {
    // 获取手机号
   async getPhoneNumber(e: any) {
      // 参数e是绑定的授权方法自动传入过来的, 为了获取到iv和encryptedData值，让后端解析手机号
      // console.log(e);
      if (e.detail.errMsg === 'getPhoneNumber:ok') {
        console.log(e.detail);
		let encryptedData=e.detail.encryptedData
        // 后台通过code，获取手机号 https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/user-info/phone-number/getPhoneNumber.html
		const data  = await decryptData({encryptedData});
		console.log(data)
      } else {
        console.log('授权登录失败')
      }

    },

  }
})
</script>

<style lang="scss" scoped>
.auther-box {
  width: 100%;
  min-height: 100vh;
}

.logo-img {
  margin: 100rpx auto;
  display: block;
}

.btn {
  width: 100%;

  button {
    width: 670rpx;
    margin: 80rpx auto 0;
    height: 90rpx;
    background: #DF8585;
    border-radius: 45rpx;
    line-height: 90rpx;
    text-align: center;
    font-size: 36rpx;
    color: #fff;
  }
}
</style>
